package main

import (
	"github.com/gin-gonic/gin"
	_ "github.com/go-sql-driver/mysql"
	"github.com/spf13/viper"
	"oceanLearn/common"
	"oceanLearn/routes"
	"os"
)

func main() {
	InitConf()
	common.InitDB()
	r := gin.Default()
	r = routes.Routes(r)
	addr := viper.GetString("server.port")
	panic(r.Run(":"+addr))
}

func InitConf() {
	workDir, _ := os.Getwd()
	viper.SetConfigName("conf")
	viper.SetConfigType("yml")
	viper.AddConfigPath(workDir + "/config")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
}
